package solutions.leetcode.easy;

import solutions.lib.BaseSolution;

/**
 * @author lizhidong
 * <a href="https://leetcode-cn.com/problems/count-special-quadruplets/">1995.统计特殊四元组</a>
 */
public class Solution1995 extends BaseSolution {

    public int countQuadruplets(int[] nums) {
        int n = nums.length;
        int result = 0;

        for (int i = 0; i < n - 3; i++) {
            for (int j = i + 1; j < n - 2; j++) {
                for (int k = j + 1; k < n - 1; k++) {
                    for (int l = k + 1; l < n; l++) {
                        int sum = nums[i] + nums[j] + nums[k];
                        result += sum == nums[l] ? 1 : 0;
                    }
                }
            }
        }
        return result;
    }

    public static void main(String[] args) {
        Solution1995 solution = new Solution1995();
        int r = solution.countQuadruplets(new int[]
                        {28,8,49,85,37,90,20,8}
                );
        System.out.println(r);
    }
}